﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using HR.Appointments.Service.ValueObjects;

namespace HR.Appointments.Service.Test
{
    [TestFixture]
    public class TestReservedTime
    {
        [SetUp]
        public void SetUp()
        {
            MockDao.SetUp();
        }

        [TearDown]
        public void TearDown()
        {
            MockDao.TearDown();
        }

        [Test]
        public void MockLoad()
        {
            var reservedTime = DAO.Instance.ReservedTime.GetByDate(1, DateTime.Parse("28.4.2008"));

            Assert.AreEqual(2, reservedTime.Count);

            Assert.AreEqual(TimeUnit.Create(12, 0), reservedTime[0].FromTime);
            Assert.AreEqual(TimeUnit.Create(13, 30), reservedTime[0].ToTime);

            Assert.AreEqual(TimeUnit.Create(15, 30), reservedTime[1].FromTime);
            Assert.AreEqual(TimeUnit.Create(16, 0), reservedTime[1].ToTime);
        }

        [Test]
        public void GetOccupiedTimeSlots()
        {
            var reservedTime = DAO.Instance.ReservedTime.GetByDate(1, DateTime.Parse("28.4.2008"));

            Assert.AreEqual(2, reservedTime.Count);

            List<TimeUnit> revSlots = reservedTime[0].GetReservedSlots(
                DateTime.Parse("28.4.2008"));

            Assert.AreEqual(27, revSlots.Count);

            revSlots = reservedTime[1].GetReservedSlots(
                DateTime.Parse("28.4.2008"));

            Assert.AreEqual(1, revSlots.Count);

            revSlots = reservedTime[0].GetReservedSlots(
                DateTime.Parse("29.4.2008"));

            Assert.AreEqual(0, revSlots.Count);

            revSlots = reservedTime[0].GetReservedSlots(
                DateTime.Parse("27.4.2008"));

            Assert.AreEqual(24, revSlots.Count);


            revSlots = reservedTime[1].GetReservedSlots(
                DateTime.Parse("29.4.2008"));

            Assert.AreEqual(0, revSlots.Count);

            revSlots = reservedTime[1].GetReservedSlots(
                DateTime.Parse("27.4.2008"));

            Assert.AreEqual(0, revSlots.Count);

        }
    }
}
